// 引入二次封装的 axios
import server from './request'

// export default 全部抛出 
// 使用 import api from "@/http/request.js" 引入 
// 通过 api.XXX 调用
export default {
    //渲染商品列表
    GoodsList(model) {
        let data = server.get("/goods", { params: model })
        return data
    },
    //添加商品
    AddGoods(model) {
        let data = server.post("/goods", model)
        return data
    },
    // 编辑商品
    UpdataGoods(model) {
        let data = server.put(`/goods/${model.goods_id}`, model)
        return data
    },
    //删除商品
    delGoods(id) {
        let data = server.delete(`/goods/${id}`)
        return data
    },


    //渲染分类列表
    CategoriesList(model) {
        let data = server.get("/categories", { params: model })
        return data
    },
    //添加分类
    AddCategories(model) {
        let data = server.post("/categories", model)
        return data
    },
    // 编辑分类
    UpdataCategories(model) {
        let data = server.put(`/categories/${model.cat_id}`, model)
        return data
    },
    //删除分类
    delCategories(id) {
        let data = server.delete(`/categories/${id}`)
        return data
    },



    //商品参数
    AttributeList(id, sel) {
        let data = server.get(`/categories/${id}/attributes?sel=${sel}`)
        return data
    },
    //添加商品参数
    AddAttribute(id, model) {
        let data = server.post(`categories/${id}/attributes`, model)
        return data
    },
    //编辑商品参数
    UpdataAttribute(id, model) {
        let data = server.put(`categories/${id}/attributes/${model.attr_id}`, model)
        return data
    },
    //删除商品参数
    delAttribute(id, attrId) {
        let data = server.delete(`categories/${id}/attributes/${attrId}`)
        return data
    },

    //图表
    CreatedReports(model) {
        let data = server.get(`/reports/type/1`, model)
        return data
    }


}
